// 商品模块对应接口
import { request } from '@/api/index.js'

// 按条件搜索商品的接口请求
export const useGoodsService = async (parms) => {
  return request.get('/goods/list', {
    params: parms
  })
}

// 获取所有商品分类的接口请求
export const useGetGoodsCategoryService = async () => {
  return request.get('/category/list')
}

// 根据商品id获取商品详情信息的接口请求
export const useGetGoodsDetailByIdService = (id) => {
  return request.get(`/goods/detail`, { params: { goodsId: id } })
}

// 根据商品id获取商品评论的接口请求
export const useGetGoodsCommentByGoodsIdService = async (
  goodsId,
  limit = 5
) => {
  return request.get(`/comment/listRows`, {
    params: {
      goodsId,
      limit
    }
  })
}

// 获取商品保障的回调
export const useGetGoodsPromiseService = async (goodsId) => {
  return request.get('/goods.service/list', { params: { goodsId } })
}
